+Sat Jan 19 20:49:20 2002 Manish Singh <yosh@gimp.org>
+
+ * io-jpeg.c, io-png.c: Made sure all the error cases involving
+ jpeg or png load/saves clean themselves up properly. Marked some
+ variables needed for cleanup volatile so they aren't clobbered by
+ setjmp.
+
Fri Jan 11 18:05:07 2002 Owen Taylor <otaylor@redhat.com>
* pixops/pixops.c: Fix integer overflow for the values
gdk_pixbuf__jpeg_image_load (FILE *f, GError **error)
{
gint w, h, i;
- guchar *pixels = NULL;
+ guchar * volatile pixels = NULL;
guchar *dptr;
guchar *lines[4]; /* Used to expand rows, via rec_outbuf_height,
* from the header file:
if (sigsetjmp (jerr.setjmp_buffer, 1)) {
/* Whoops there was a jpeg error */
if (pixels)
- free (pixels);
+ g_free (pixels);
jpeg_destroy_decompress (&cinfo);
return NULL;
cinfo.err = jpeg_std_error (&(jerr.pub));
if (sigsetjmp (jerr.setjmp_buffer, 1)) {
jpeg_destroy_compress (&cinfo);
- free (buf);
+ g_free (buf);
return FALSE;
}
/* finish off */
jpeg_finish_compress (&cinfo);
- free (buf);
+ g_free (buf);
return TRUE;
}
gboolean failed = FALSE;
gint i, ctype, bpp;
png_uint_32 w, h;
- png_bytepp rows;
- guchar *pixels;
+ png_bytepp volatile rows = NULL;
+ guchar * volatile pixels = NULL;
gint num_texts;
gchar **options = NULL;
}
if (setjmp (png_ptr->jmpbuf)) {
+ if (rows)
+ g_free (rows);
+
+ if (pixels)
+ g_free (pixels);
+
png_destroy_read_struct (&png_ptr, &info_ptr, &end_info);
return NULL;
}
int has_alpha;
int bpc;
int num_keys;
+ gboolean success = TRUE;
num_keys = 0;
info_ptr = png_create_info_struct (png_ptr);
if (info_ptr == NULL) {
- png_destroy_write_struct (&png_ptr, (png_infopp) NULL);
- return FALSE;
+ success = FALSE;
+ goto cleanup;
}
if (setjmp (png_ptr->jmpbuf)) {
- png_destroy_write_struct (&png_ptr, (png_infopp) NULL);
- return FALSE;
+ success = FALSE;
+ goto cleanup;
}
if (num_keys > 0) {
}
png_write_end (png_ptr, info_ptr);
+
+cleanup:
png_destroy_write_struct (&png_ptr, (png_infopp) NULL);
if (num_keys > 0) {
g_free (text_ptr);
}
- return TRUE;
+ return success;
}